var dotIndex = 0;
var index = 0;
var slideshow=0;
var isPlay = false;
var asideIndex =0;
var tt ='';
var isScroll = false;
var userId = Math.floor(Math.random()*10000);
var isPC = $(window).width()>1080;
function interval(){
slideshow=setInterval(function(){
    if(index>3){index=0};
    $('.dot>li').eq(index).trigger('click');
    index++;
},5000);
};
function formatterDateTime() {
    var date=new Date();
    var month=date.getMonth() + 1;
          var datetime = date.getFullYear()
                  + ""
                  + (month >= 10 ? month : "0"+ month)
                  + ""
                  + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate())
                  + ""
                  + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours())
                  + ""
                  + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes())
                  + ""
                  + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
          return datetime;
      };
     
function changetext(){
    $.ajax({
        type: 'post',
        url: 'http://route.showapi.com/1211-1',
        dataType: 'json',
        data: {
            "showapi_timestamp": formatterDateTime(),
            "showapi_appid": '165577',
            "showapi_sign": '02956c230f6d4fa3a2afdbe155b5d0bc', 
            "count":"4"
        },

        error: function(XmlHttpRequest, textStatus, errorThrown) {
            console.log('获取文字失败.')
        },
        success: function(result) {
            var divbox = $('.saying');
            var data = result.showapi_res_body.data;
            data.forEach(function(val,index){
                $(divbox[index]).children().eq(0).text(val.chinese);
                $(divbox[index]).children().eq(1).text(val.english);
            })
        }
    });
};
document.onreadystatechange=function(){
    if(this.readyState == 'complete'){
        $('.first-screen').hide();
        if (window.matchMedia('(max-width: 1080px)').matches) {
            $('body').css('overflow-y','scroll');
            changetext();
            $('#testaudio')[0].play();
          }
    }
};
$(function(){
    interval();
    setTimeout(function(){
        $('.wrap').css('top',0); 
    },200);
    window.addEventListener('beforeunload',function(){
        $('.wrap').css('top',0);
        $('.aside_change li').eq(0).trigger('click');
    });
    $('.audio').click(function(){
        if(isPlay){
            $('#testaudio')[0].pause();
            $(this).children().css('animation-name','none');
            isPlay = false;
        }else{
            $('#testaudio')[0].play();
            $(this).children().css('animation-name','musicOne');
            isPlay = true;
        } 
    });
    $('#testaudio').on('ended',function(){
        $('.audio').children().css('animation-name','none');
    });
    $('#testaudio').on('play',function(){
        console.log('已调用');
        $('.audio').children().css('animation-name','musicOne'); 
        isPlay=true; 
    });
    $('.wrap>section').outerHeight($(window).height());
    $('.search li').click(function(){
        $(this).css({'border-color':'#2ecc71','color':'white'}).siblings().css({'border-color':'transparent','color':'rgba(189, 195, 199,1.0)'});
    });

    $('.enter').click(function(ev){
        var visible = $('.option_box').css('display');
        if(visible == 'block'){
            $('.slid').trigger('click');
        };
        if($(window).width() <= 1080){
            $(this).siblings().slideToggle()
        };
        ev.stopPropagation();
        
    });
    $('.page_one').click(function(ev){
        var visible = $('.option_box').css('display');
        if(visible == 'block'){
            $('.slid').siblings().slideUp();
        };
        if($(window).width() <= 1080){
            $('.enter').siblings().slideUp();
        };
    });
    //****************************第二页动画************** */
    
    
    $('.scroll_bar').mouseenter(function(){
        clearInterval(slideshow)
    });
    $('.scroll_bar').mouseleave(function(){
        interval();
    });
    $('.dot>li').click(function(){
        index = $(this).addClass('active').siblings().removeClass().end().index();
        
        if(index>dotIndex){
        dotIndex = index;
        $('.scroll_bar>div').removeClass().find('p').css('visibility','hidden');
        $('.scroll_bar>div').eq(index-1).addClass('leftHide');
        $('.scroll_bar>div').eq(index).addClass('rightShow').find('p').css('visibility','visible');
        }else if(index<dotIndex){
        dotIndex = index;
        $('.scroll_bar>div').removeClass().find('p').css('visibility','hidden');
        $('.scroll_bar>div').eq(index+1).addClass('rightHide');
        $('.scroll_bar>div').eq(index).addClass('leftShow').find('p').css('visibility','visible');
        }      
    });
    
    /*************************首页交互***********************************/
    $('.navbar .change_page').click(function(){
        // $(this).children().css('color','rgba(83, 82, 237,1.0)');
        // $(this).siblings().children().css('color','rgba(241, 242, 246,.8)');
        var index = $(this).index()-1;
        $('.aside_change li').eq(index).trigger('click');
    });
    $('.aside_change li').click(function(){
        asideIndex=$(this).addClass('active').siblings().removeClass().end().index();
        var top =-asideIndex * $(window).height();
        $('.wrap').css('top',top);
        if(asideIndex == 1){
            changetext()
        }
        
    });
    $('.page_three>.main').mouseenter(function(){
        isScroll = true;
    });
    $('.page_three>.main').mouseleave(function(){
        isScroll = false;
    });
    var timer1 = null;
    $('.wrap')[0].addEventListener('mousewheel',function(ev){
        ev.preventDefault();
        if($('.search').css('display') == 'block' || (isScroll && isPC)) return false;
        var d = ev.wheelDelta;
        
        var h =$(window).height();
        var top = parseInt($('.wrap').css('top'));
        if(d<0 && top>(-4*h)){
            clearTimeout(timer1)
            timer1 = setTimeout(function(){
                top -= h;
                $('.wrap').css('top',top);
                asideIndex++;
                $('.aside_change li').eq(asideIndex).trigger('click');
            },500)
        }else if(d>0 && top<0){
            clearTimeout(timer1)
            timer1 = setTimeout(function(){
                top +=  h;
                $('.wrap').css('top',top);
                asideIndex--;
                $('.aside_change li').eq(asideIndex).trigger('click');
            },500)
        }
    });
    var timer2 = null;
    
    $('.wrap')[0].addEventListener('DOMMouseScroll',function(ev){
        // ev.preventDefault();
        if($('.search').css('display') == 'block' || (isScroll && isPC)) return false;
        var d = ev.detail; 
        
        var h =$(window).height();
        var top = parseInt($('.wrap').css('top'));
        if(d>0 && top>(-4*h)){
            clearTimeout(timer2);
            timer2 = setTimeout(function(){
                top -= h;
                $('.wrap').css('top',top);
                asideIndex++;
                $('.aside_change li').eq(asideIndex).trigger('click');
            },500)
        }else if(d<0 && top<0){
            clearTimeout(timer2)
            timer2 = setTimeout(function(){
                top +=  h;
                $('.wrap').css('top',top);
                asideIndex--;
                $('.aside_change li').eq(asideIndex).trigger('click');
            },500)
        }       
    });
    $('.selector').on('click','.slid',function(ev){
        $(this).children().toggleClass('rotate');
        $(this).siblings().slideToggle();
        if($(window).width() <= 1080){
            $('.enter').siblings().slideUp();
        };
        ev.stopPropagation();
    });

    $('.colose').click(function(ev){
        $('.search').hide();
        $('.sear_top>div').eq(0).trigger('click');
        $('.test_options>div:eq(0)').trigger('click');
        $('.idiom_options').children().eq(0).trigger('click');
        $('.gl_input>input').val('');
        $('.IP_options div:eq(0)').trigger('click');
        if (window.matchMedia('(max-width: 1080px)').matches) {
            $('body').css('overflow-y','scroll');
          };
        var obj = $('.cts_options>div');
        
        for(var i=0;i<obj.length;i++){
            if(i===0 || i===2 || i===7){
                $(obj[i]).trigger('click');
            }
        }

    });
    $('.option>div').click(function(){
        $('.search').show();
        $('.sear_top>div').eq($(this).index()).trigger('click');
        $('body').css('overflow-y','hidden');
    });
    $('.sear_top>div').click(function(){
        var index = $(this).addClass('top_active').siblings().removeClass().end().index();
        $('.gl_input>input').val('');
        if(index ===1){
            $('.IP_options').show();
            $('.innerwrap_two label').text('输入IP地址:').siblings().attr('placeholder','例:116.4.201.181');
        };
        if(index === 2){
            index=1;
            $('.IP_options').hide();
            $('.innerwrap_two label').text('输入手机号码:').siblings().attr('placeholder','例:18222222231');
        };
        if(index>2){index--};

        $('.sear_bottom>div').eq(index).css('z-index','1').siblings().css('z-index','0');
    });
    $('.cts_options>div').click(function(){
        $(this).addClass('selector_active').siblings().removeClass();

    });
    $('.test_options>div').click(function(){
        $(this).addClass('test_active').siblings().removeClass();
        var node_div = $('<div class="gl_input"></div>');
        var node_label=$('<label for="ming">名:</label>');
        var node_input=$('<input type="text" id="ming" placeholder="例:羊羊" required>');
        $('.import input').val('')
        switch($(this).index()){
            case 0:
                if($('.import>div').length < 2){
                $('.import>div>label').attr('for','xing').text('姓:');
                $('.import>div>input').attr({'id':'xing','placeholder':'例:喜'});
                node_div.append(node_label);
                node_div.append(node_input);
                $('.import').append(node_div);};
                break;
            case 1:
                $('.import>div:eq(1)').remove();
                $('.import>div>label').attr('for','company').text('公司名称:');
                $('.import>div>input').attr({'id':'company','placeholder':'例:阿里某某技术有限公司'});
                break;
            case 2:
                $('.import>div:eq(1)').remove();
                $('.import>div>label').attr('for','QQ').text('QQ号码:');
                $('.import>div>input').attr({'id':'QQ','placeholder':'例:156****694'});
                break;
            case 3:
                $('.import>div:eq(1)').remove();
                $('.import>div>label').attr('for','catnum').text('车牌号码:');
                $('.import>div>input').attr({'id':'catnum','placeholder':'例:川A8***8'});
                break;
            case 4:
                $('.import>div:eq(1)').remove();
                $('.import>div>label').attr('for','phonenum').text('手机号码:');
                $('.import>div>input').attr({'id':'phonenum','placeholder':'例:186*****654'});
                break;
        }
    });
    
    $('.idiom_options>div').click(function(){
        $(this).addClass('test_active').siblings().removeClass();
        var index = $(this).index();
        $('.idiom_import input').val('');
        if(index==0){
            $('.idiom_import label:eq(0)').text('输入成语:').siblings().attr('placeholder','例:掩耳盗铃');
            $('.gl_button').hide();
            
        }else if(index == 1){
            $('.idiom_import label:eq(0)').text('输入关键字:').siblings().attr('placeholder','例:铃');
            $('.gl_button').show();
            $('.gl_button input').val(10);
        }
    });
    $('.IP_options>div').click(function(){
        $(this).addClass('test_active').siblings().removeClass();
        var index = $(this).index();
        $('.innerwrap_two input').val('');
        if(index==0){
            $('.innerwrap_two .gl_input label').text('输入IP地址:').siblings().attr('placeholder','例:116.4.201.181');
            
        }else if(index == 1){
            $('.innerwrap_two .gl_input label').text('输入域名:').siblings().attr('placeholder','例:www.baidu.com');
        }
    });
    // ********************************首页查询********************************************

    $('.gl_button>button').click(function(){
        var index = $(this).index();
        var num = $('#idiom_key').val();
        if(index == 1){
            num--;
            $('#idiom_key').val(num);
        }else if(index == 3){
            num++;
            $('#idiom_key').val(num);
        }
    });
    $('.shut>button').click(function(){

        $(this).parent().parent().css('bottom','100%');
    });
    function params(data){
        if(typeof data == 'object'){
            return data;
        }else if(typeof data == 'function'){
            return data();
        }
    };
    function lookResult(isCenter){
        if(isCenter){
            $('.sear_result').css('bottom',0).children('.content_box').css({
                'justify-content':'center',
                'text-align':'center'
            });
        }else{
            $('.sear_result').css('bottom',0).find('.content_box').css({
                'justify-content':'flex-start',
                'text-align':'left'
            });
        }
    };
    function queryParams(){
        var num = $('.selector_active').eq(0).attr('data-num');
        var type = $('.selector_active').eq(1).attr('data-type');
        var yayuntype = $('.selector_active').eq(2).attr('data-yayuntype');
        var key = $('#key').val();
        return {num:num,type:type,yayuntype:yayuntype,key:key};
    };
    // 错误处理回调
    function errorHandle(a,b,c){
        var div = $('<div></div>');
        var h3 = $('<h4>故障提示!</h4>');
        var p =$('<p>网络可能抛锚了...</p>');
        div.append(h3,p);
        $('.content_box').empty().append(div);
        lookResult(true);

    };
    //藏头诗回调
    function ctstHandle(result){
        var resBody = result.showapi_res_body.list;
        var remark = result.showapi_res_body.remark ||result.showapi_res_error;
        var div = $('<div></div>');
        if(result.showapi_res_body.ret_code == 0){
            for(var i=0;i<resBody.length;i++){
                var p =$('<p>'+resBody[i]+'</p>');
                div.append(p);
            }
        }else{
            var p =$('<p>'+remark+'</p>');
                div.append(p);
        }
        
        $('.content_box').empty().append(div);
        lookResult(true);
    };

    
    //域名,ip,手机归属回调
    function domainCallback(result,obj){
        var resBody = result.showapi_res_body;
        var remark = result.showapi_res_body.remark || result.showapi_res_error;
        var div = $('<div></div>');
        // var obj = {'洲':'continents','国家':'country','国家英文名':'en_name','国家英文名简写':'en_name_short','省份':'region','城市':'city','城市编码':'city_code','乡镇':'county','运营商':'isp','经度':'lnt','纬度':'lat','ip地址':'ip'};
        if(result.showapi_res_body.ret_code == 0){
            for(var key in obj){
                
                var value = obj[key];
                var attr = resBody[value] ? resBody[value] : '';
                var p = $('<p><span>'+key+':</span>'+attr+'</p>');
                div.append(p);
            }
        }else{
            var p =$('<p>'+remark+'</p>');
                div.append(p);
        }
        $('.content_box').empty().append(div);
        lookResult(true);
    };
    //姓名打分回调
    function nameCallback(result){
        var resBody = result.showapi_res_body;
        var remark = result.showapi_res_body.remark || result.showapi_res_error;

        $('.content_box').empty();
        if(resBody.ret_code != 0){
            var div = div = $('<div></div>');
            var p =$('<p>'+remark+'</p>');
                div.append(p);
                $('.content_box').append(div);
                lookResult(true);
        }else if(resBody.ret_code == 0){
            resBody.contentList.forEach(function(val){

                var text = val.expList;
                var div = $('<div></div>');
                var h4 =$('<h4>'+val.title+'</h4>');
                div.append(h4);
                for(var i=0;i<text.length;i++){
                    var p = $('<p>'+text[i]+'</p>');
                    div.append(p);
                }
                
                $('.content_box').append(div);   
            })
            lookResult(false);
        }
        
    };
    //公司 车牌 手机 QQ号测吉凶回调
    function otherCallback(result){
        var resBody = result.showapi_res_body;
        var remark = result.showapi_res_body.remark || result.showapi_res_error;
        $('.content_box').empty();
        var div = div = $('<div></div>');
        if(resBody.ret_code != 0){
            var p =$('<p>'+remark+'</p>');
                div.append(p);
                $('.content_box').append(div);
        }else if(resBody.ret_code == 0){
            var h4 =$('<h4>'+resBody.title+'</h4>');
            div.append(h4);
            var text = resBody.expList;
            for(var i=0;i<text.length;i++){
                var p = $('<p>'+text[i]+'</p>');
                div.append(p)
            }
            $('.content_box').append(div); 
        }
        lookResult(true);
    };
    //成语大全回调
    function idiomCallback(result){
        var resBody = result.showapi_res_body;
        var remark = result.showapi_res_body.remark || result.showapi_res_error;
        $('.content_box').empty();
        var div = $('<div></div>');
        if(resBody.ret_code != 0){
            var p =$('<p>'+remark+'</p>');
                div.append(p);
                $('.content_box').append(div);
        }else if(resBody.ret_code == 0){
            if(resBody.data instanceof Array){
                resBody.data.forEach(function(val){
                    var p = $('<p>'+val.title+'</p>');
                    div.append(p);
                },this);
                $('.content_box').append(div);
            }else if(resBody.data instanceof Object){
                var idiObj = {'成语名称':'title','拼写读音':'spell','解释':'content','出自典故':'derivation','例子':'samples'};
                for(var key in idiObj){
                    var ke = idiObj[key];
                    var text = resBody.data[ke] ? resBody.data[ke] : '';
                    var p = $('<p><span>'+key+'--</span>'+text+'</p>');
                    div.append(p);
                }
                $('.content_box').append(div); 
            }
        }
        lookResult(true);
    };
    //发送请求
    function queryInfo(url,data,errorfn,successfn,nameObj){
        var defDate = {"showapi_timestamp": formatterDateTime(),
                        "showapi_appid": '165577',
                        "showapi_sign": '02956c230f6d4fa3a2afdbe155b5d0bc'};

        $.ajax({type:'post',
                url:url,
                dataType:'json',
                data:$.extend(defDate,params(data)),
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    errorfn(XmlHttpRequest, textStatus, errorThrown)
                },
                success: function(result){
                    successfn(result,nameObj)
                }
            })
    };
    
    $('.query').eq(0).click(function(){
        $(this).prop('disabled','true');
        tt = $(this);
        setTimeout(function(){
            tt.removeProp('disabled');
        },2000);
        var ctsUrl = $('.top_active').attr('data-url');
        queryInfo(ctsUrl,queryParams,errorHandle,ctstHandle);
    });
    $('.query:eq(1)').click(function(){
        $(this).prop('disabled','true');
        tt = $(this);
        setTimeout(function(){
            tt.removeProp('disabled');
        },2000);
        var phoneUrl = $('.top_active').attr('data-url');
        var ipUrl = $('.test_active:eq(0)').attr('data-url');
        var params = $('.gl_input:eq(1)>input').val();
        if(!phoneUrl){
            var end = ipUrl.charAt(ipUrl.length-1)
            if(end == 1){
                var IpObj = {'国家':'country','国家英文名':'en_name','国家英文名简写':'en_name_short','片区':'area','省级':'region','城市':'city','城市编码':'city_code','县级':'county','运营商':'isp','经度':'lnt','纬度':'lat'};
                queryInfo(ipUrl,{ip:params},errorHandle,domainCallback,IpObj);
            }else{
                var domainObj = {'洲':'continents','国家':'country','国家英文名':'en_name','国家英文名简写':'en_name_short','省份':'region','城市':'city','城市编码':'city_code','乡镇':'county','运营商':'isp','经度':'lnt','纬度':'lat','ip地址':'ip'};
                queryInfo(ipUrl,{domain:params},errorHandle,domainCallback,domainObj);
            }
            
        }else{
            var phoneObj = {'省份':'prov','城市':'city','运营商':'name','号段':'num','分类':'type','省别编码':'provCode','城市编码':'cityCode','邮政编码':'postCode','城市区号':'areaCode'};
            queryInfo(phoneUrl,{num:params},errorHandle,domainCallback,phoneObj);
        }

    });
    
    $('.query').eq(2).click(function(){
        $(this).prop('disabled','true');
        tt = $(this);
        setTimeout(function(){
            tt.removeProp('disabled');
        },2000);
        var testUrl = $('.test_options .test_active').attr('data-url');
        var end = testUrl.charAt(testUrl.length-1);
        var firstName = $('.gl_input:eq(2)>input').val();
        var lastName = $('.gl_input:eq(3)>input').val();
        switch(end-0){
            case 5:
                queryInfo(testUrl,{surname:firstName,name:lastName},errorHandle,nameCallback);
                break;
            case 4:
                queryInfo(testUrl,{companyName:firstName},errorHandle,otherCallback);
                break;
            case 3:
                queryInfo(testUrl,{qq:firstName},errorHandle,otherCallback);
                break;
            case 2:
                queryInfo(testUrl,{carNo:firstName},errorHandle,otherCallback);
                break;
            case 1:
                queryInfo(testUrl,{mobile:firstName},errorHandle,otherCallback);
                break;

        }
    });
    $('.query').eq(3).click(function(){
        $(this).prop('disabled','true');
        tt = $(this);
        setTimeout(function(){
            tt.removeProp('disabled');
        },2000);
        var idiomUrl = $('.idiom_options .test_active').attr('data-url');
        var end = idiomUrl.charAt(idiomUrl.length-1);
        var idiom= $('.gl_input:eq(4)>input').val();
        var idiomKey = $('.gl_button>input').val();
        if(end == 2){
            queryInfo(idiomUrl,{keyword:idiom},errorHandle,idiomCallback);
        }else if(end == 1){
            queryInfo(idiomUrl,{keyword:idiom,page:1,rows:idiomKey},errorHandle,idiomCallback);
        }
    });
    /****************************聊天********************** */
    var scrollTop = '';
    function chatError(){
        var pre = $('<pre></pre>').text('故障提示:机器人都被玩儿坏了!');
        acceptBox.find('.accept_content>pre').replaceWith(pre);
        $('.chat_window').append(acceptBox);
        var h = $('.chat_window>div:nth-last-child(1)').outerHeight(true);
        $('.chat_window').scrollTop(scrollTop+h);
        scrollTop=$('.chat_window').scrollTop();
    };
    function chatSuccess(result){
        var acceptBox = $('.accept:eq(0)').clone();
        var pre = $('<pre></pre>');
        if(result.showapi_res_code != 0){
            pre.text('错误提示:'+result.showapi_res_error);
        }else{
            pre.text(result.showapi_res_body.text); 
        }
        acceptBox.find('.accept_content>pre').replaceWith(pre);
        $('.chat_window').append(acceptBox);
        var h = $('.chat_window>div:nth-last-child(1)').outerHeight(true);
        $('.chat_window').scrollTop(scrollTop+h);
        scrollTop=$('.chat_window').scrollTop();
    };
    $('.chat_window').scroll(function(ev){
        var top = $(this).scrollTop();
        $(this).scrollTop(top);
    });
    
    $('.edit_frame button').click(function(){
        var letter = $('#letter').val();
        var isEmpty = letter.trim();
        var chatUrl = 'https://route.showapi.com/60-27';
        var isNone = $('.send').css('display') == 'none';
        if(!!isEmpty && isNone){
            // $('.send>pre').text(letter).parent().parent().parent().show();
            $('.send').css('display','flex').find('pre').text(letter).end().find('span').text(userId);
            queryInfo(chatUrl,{info:letter,userid:userId},chatError,chatSuccess);
        }else if(!!isEmpty){
            var sendBox = $('.send:eq(0)').clone();
            var pre = $('<pre></pre>').text(letter);
            sendBox.find('.send_content>pre').replaceWith(pre);
            sendBox.find('.send_content>span').text(userId);
            $('.chat_window').append(sendBox);
            var h = $('.chat_window>div:nth-last-child(1)').outerHeight(true);
            $('.chat_window').scrollTop(scrollTop+h);
            
            scrollTop=$('.chat_window').scrollTop();
            
            queryInfo(chatUrl,{info:letter,userid:userId},chatError,chatSuccess);
        }
        $('#letter').val('');
    });
    $('#letter').keyup(function(ev){
        if(event.ctrlKey&&event.keyCode==13){
            var text = $('#letter').val();
            $('#letter').val(text + '\n'); 
        }else if(ev.keyCode == 13){
            $('.edit_frame button').click();
        }
    });
    $('#letter').on('focus',function(){
        if(!isPC){
            $('.page_three > .main').addClass('fixedlayout');
            
        }

    });
    $('#letter').on('blur',function(){
        if(!isPC){
            $('.page_three > .main').removeClass('fixedlayout');         
        }
    });
    /**********************第五页******************* */
    var imgw = $('.five_img:eq(0)').width();
    var img = $('.five_img');
    var img0 = {
        x:$('.five_img:eq(0)').position().left+imgw/2,
        y:$('.five_img:eq(0)').position().top+$('.five_img:eq(0)').height()/2,
    };
    var img1 = {
        x:$('.five_img:eq(1)').position().left+imgw/2,
        y:$('.five_img:eq(1)').position().top+$('.five_img:eq(1)').height()/2,
    };
    var img2 = {
        x:$('.five_img:eq(2)').position().left+imgw/2,
        y:$('.five_img:eq(2)').position().top+$('.five_img:eq(2)').height()/2,
    };
    $('.page_five>.main').mousemove(function(ev){
        
        var initial = 120;
        var img0L = Math.sqrt((Math.pow(img0.x-ev.clientX,2)+Math.pow(img0.y-ev.clientY,2)));
        var img1L = Math.sqrt(Math.pow(img1.x-ev.clientX,2)+Math.pow(img1.y-ev.clientY,2));
        var img2L = Math.sqrt(Math.pow(img2.x-ev.clientX,2)+Math.pow(img2.y-ev.clientY,2));
        if(initial > img0L){
            img.eq(0).width(imgw + (initial-img0L) + 'px')
        }
        if(initial > img1L){
            img.eq(1).width(imgw + (initial-img1L) + 'px')
        }
        if(initial > img2L){
            img.eq(2).width(imgw + (initial-img2L) + 'px')
        }
    });
    $('.page_five>.main').mouseleave(function(ev){
        for(var i=0;i<3;i++){
            img.eq(i).width(imgw+'px');
        }
    });
})






